package com.cc.cbdb.fragment;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.cc.cbdb.R;
import com.cc.cbdb.adapter.DataListAdapter;
import com.cc.cbdb.entity.QBiogCustom;

import java.util.ArrayList;

/**
 * A simple {@link Fragment} subclass.
 */
public class RecommendFragment extends Fragment {

    private static final String TAG = "RecommendFragment";

    private DataListAdapter adapter;
    private ArrayList<QBiogCustom> recommendData;
    private ListView lv;

    public RecommendFragment() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_recommend, container, false);
        lv = view.findViewById(R.id.lv_recommend);
        return view;
    }


    public void updataFragment(){
        Bundle bundle = getArguments();
        if (bundle != null) {
            recommendData = bundle.getParcelableArrayList("recommendData");
            if (adapter == null) {
                adapter = new DataListAdapter(getActivity(),recommendData);
                lv.setAdapter(adapter);
            }else {
                adapter.notifyDataSetChanged();
            }
        }
    }
}
